#!/bin/bash

current_time=`adb shell date "+%y_%m_%d_%H_%M_%S"`
mkdir process_top_$current_time
cd process_top_$current_time
exec 1>system_process_top_$current_time.txt
isRunning=true
trap isRunning=false SIGINT
while $isRunning
do 
	echo "-------------------`adb shell date "+%y-%m-%d %T"`----------------------"
	adb shell top -d 1 -n 1
done

gawk '/.*(com\.htc\.wavevr\.platform_perf_certif_tool)$/{printf("process[%s], cpu[%s]\n", $11,$5);}' system_process_top_$current_time.txt > platform_perf_certif_tool_CPU_Usage.txt
gawk '/^(User.*,)/{printf("User CPU Usage: %d%,		System CPU Usage: %d%,		Total CPU Usage: %d%\n",int($2), int($4), int($2)+int($4));}' system_process_top_$current_time.txt > CPU_Usage.txt

cd ../
